<?php

namespace app\mobile\controller;

use app\common\controller\Frontend;
use think\Db;
use think\Request;

class Cihui extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function index()
    {
		$banner=Db::name('banner')->where([
			'type_data'=>1,
			'bannertype_id'=>7
		])->find();

		$this->assign('banner',$banner);

        return $this->view->fetch();
    }

    public function ajax_fanyi(Request $request){
        if($request->isAjax()){
            $keyword=$this->request->param('keyword/s','');
            $rs=Db::name('cihui')->where(['word'=>$keyword])->find();
            if(is_null($rs)){
                return json(['code'=>0,'msg'=>'没有查询到对应内容']);
            }else{
                Db::name('cihui')->where(['id'=>$rs['id']])->setInc('weigh');
                return json(['code'=>1,'data'=>$rs]);
            }
        }
    }

	public function fanyi(){
		$banner=Db::name('banner')->where([
			'type_data'=>1,
			'bannertype_id'=>7
		])->find();

		$this->assign('banner',$banner);



		$keyword=$this->request->param('keyword/s','');
		$rs=Db::name('cihui')->where(['word'=>$keyword])->find();
		Db::name('cihui')->where(['id'=>$rs['id']])->setInc('weigh');

		$this->assign('rs',$rs);
		$this->assign('keyword',$keyword);
		$this->assign('empty','<div class="empty">
					<div>
						<img src="/mobile/img/ico_empty.png" >
						<p>没有查询到对应内容</p>
					</div>
				</div>');
		return $this->view->fetch();
	}

}
